package com.karolak.stock.indicator;

import com.karolak.stock.data.DataManager;

public class SignAmplitudeInd extends Indicator {

	private Indicator sign;

	public SignAmplitudeInd(String name, DataManager dataManager,Indicator amp, Indicator sign) {
		super(name, dataManager, 0, amp);
		this.sign = sign;
	}

	@Override
	public double execute(double x) {
		double d = getDataManager().getLast(getInput().getName());
		double sign = getDataManager().getLast(getSign().getName());
		sign = Math.signum(sign);
		return sign * d;
	}

	protected Indicator getSign() {
		return sign;
	}
}
